type Toptions_Pbutton$title = Toptions_Ptext | Toptions_Ptext$text;
type Toptions_Pbutton$icon = Toptions_Picon | Toptions_Picon$icon;

type Toptions_Pbutton = {
    title?: Toptions_Pbutton$title;
    icon?: Toptions_Pbutton$icon;
} & Toptions_ONCLICK & Toptions_DISABLED & Toptions_NAME;

@AConclick
@ACdisabled
@ACname
class Pbutton extends _CP_<Toptions_Pbutton> {
    // ====================================================== 当前控件特殊实现 ====================================================== //

    // ====================================================== 初始化参数 ====================================================== //
    static defaultOptions: Toptions_Pbutton = {
    };
    protected override options_default(): Toptions_Pbutton {
        return Pbutton.defaultOptions;
    }
    protected override options_handlers(): Toptions_handlers<Toptions_Pbutton> {
        return {
            title: {
                [U.F.argType.any]: U.F.fn.obj,
                [Etype.obj]: U.F.fn.obj
            },
            icon: {
                [Etype.string]: U.F.fn.obj,
                [Etype.obj]: U.F.fn.obj
            },
        };
    }
    protected override overloading_mapping(mapping: Toption_key_to_types_mapping<Toptions_Pbutton>): Toverloading_mapping<Toptions_Pbutton> {
        return [
            [
                { key: 'onclick', types: ['function'] },
            ],
            [
                { key: 'title', types: mapping.get('title')! },
            ],
            [
                { key: 'title', types: mapping.get('title')! },
                { key: 'icon', types: mapping.get('icon')! },
            ],
            [
                { key: 'title', types: mapping.get('title')! },
                { key: 'icon', types: mapping.get('icon')! },
                { key: 'onclick', types: mapping.get('onclick')! },
            ]
        ];
    }
    protected override options_checker(options: Toptions_Pbutton): void {
        if (!Object.prototype.hasOwnProperty.call(options, 'title') && !Object.prototype.hasOwnProperty.call(options, 'icon')) {
            options.title = '';
        }
    }

    // ====================================================== 创建实例对象 ====================================================== //
    protected override initializer(): void {
        // 图标
        if (Object.prototype.hasOwnProperty.call(this.options, 'icon')) {
            K.icon(this.options.icon as Toptions_Picon).insertTo(this.ele);
        }

        // 标题
        if (Object.prototype.hasOwnProperty.call(this.options, 'title')) {
            K.text(this.options.title).insertTo(this.ele);
        }
    }
    protected override afterInitializer(): void {
    }
}

interface _IK_ {
    // ========= 创建实例对象（通用） ========= //
    /**
     * 创建控件
     * @returns 控件实例对象
     */
    button(): KHTMLElement;

    /**
     * 创建控件
     * @param options 控件参数
     * @returns 控件实例对象
     */
    button(options: Toptions_Pbutton): KHTMLElement;

    // ========= 创建实例对象（特殊） ========= //
    /**
     * 创建控件
     * @param onclick 点击事件回调方法
     * @returns 控件实例对象
     */
    button(onclick: Tevent_callback): KHTMLElement;
    /**
     * 创建控件
     * @param title 文本值
     * @param icon 图标值
     * @param onclick 点击事件回调方法
     * @returns 控件实例对象
     */
    button(title: string, icon?: Toptions_Pbutton$icon, onclick?: Tevent_callback): KHTMLElement;
}
{
    K.button = (...args: Array<any>) => { return new Pbutton(...args).ele; };
}
